<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
    	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>增配手柄</title>
	</head>
    <link rel="stylesheet" href="css/AllStyle.css" />
    <link rel="stylesheet" href="css/iconfont.css" />
    <script type="text/javascript" src="js/common.js" ></script>
    <script type="text/javascript" src="js/data.js" ></script>
    <script type="text/javascript" src="js/tmpl.js" ></script>
    <script type="text/javascript" src="js/ch.js" ></script>
    <script type="text/javascript" src="js/template.js" ></script>
	<body>
		<!-- 页头 -->
	    <section>
		    <script type="text/javascript">
		        AllPageHeader()
		    </script>
	    </section>
	    
		<!-- 页面-->
    	<section class="AllContent">
    		<div class="ScanBlock" style="padding-bottom: 60px;">
	    		<div class="grid-body" id="cententbody"></div>
	    	</div>
    	</section>
    	
	</body>
	<script type="text/javascript" src="js/jquery.min.js" ></script>
	<script type="text/javascript" src="js/mui.min.js" ></script>
	<script type="text/html" id="centent">
		<div class="ScanBlock">
	    	<form>
				<div class="unilineframe relative">
					<img class="scanimg" data-val="1" src="images/scan_01.png">
					<input id="sncode2" class="bg-focus form-control" type="text"  name="sncode2" placeholder="SN2码" value="">
				</div>
				<div class="ScanInput">
					<p class="relative">
						<img class="scanimg" data-val="2" src="images/scan_01.png">
						<input id="sncode" class="bg-focus form-control" type="text"  name="sncode" placeholder="SN码" value="">
					</p>
					<p><button type="button" style="font-size:0.9em" onclick="getNewSncode();">获取SN2码和SN码</button></p>
				</div>
			</form>
			
		</div>
        <a class="btn" id="startButton" onclick="finishPackage();">增配</a>
	</script>
		<script type="text/javascript">
		    mui.init();
		    
			$('.AllHeader li:eq(1)').text('增配手柄');
			
			$(function () {
	            //语言包渲染
	            Template_ini('centent','#cententbody');
	            document.addEventListener('deviceready', onDeviceReady, true);
	            $("#sncode").focus();
	
	        });
	        
	        mui.plusReady(function(){
			    //扫描器
			    $('.scanimg').click(function(){
			    	var val = $(this).attr("data-val");
			    	 mui.openWindow({
					    url: 'Scanner.html?etk=101&index=tag_pack&type='+val, 
					    id:'Scanner.html'
					});
			    })
			});
			
			//添加refresh自定义事件监听
			window.addEventListener('scan',function(){
				var id = event.detail.id;
				var te = event.detail.type;
				$("#sncode").val(id);
			});
			
	       function onDeviceReady() {
	            document.addEventListener("backbutton", onBackKeyDown, false);
	        }
	        function onBackKeyDown() {
	            openUrl("supper.html");
	        }
	
	        function finishPackage() {
	            var sncode = $("#sncode").val();
	            var sncode2 = $("#sncode2").val();
	            if (empty(sncode) || empty(sncode2)) {
	                alert("SN码2、SN码不能为空！");
	                return false;
	            }else{
					$("#sncode").val("");
					$("#sncode2").val("");
					alert("增配手柄成功！");
				}
	            
	        }
			function getNewSncode(){
				$("#sncode").val(guid());
				$("#sncode2").val(guid());
			}
		</script>
</html>
